<template>
  <div class="home">
    <header>
      <i class="iconfont icon-iconfontseacher"></i>
      <input type="text" class="searchBar" placeholder="search">
      <i class="iconfont icon-nav" @click="sheetVisible=!sheetVisible"></i>
      <mt-actionsheet :actions="actions" v-model="sheetVisible">
      </mt-actionsheet>
    </header>

    <div class="lists">

      <list-item v-for="item in conversations" :item="item">
      </list-item>
    </div>
    <div class="bottom">
      <div class="item " @click="$router.push('/home')">
        <i class="iconfont icon-dingdanicon"></i>
        <div>通讯录</div>
      </div>
      <div class="item active">
        <i class="iconfont icon-kefuzhongxinicon"></i>
        <div>聊天记录</div>
      </div>
    </div>
  </div>
</template>

<script>
  // @ is an alias to /src
  import HelloWorld from "@/components/HelloWorld.vue";
  import listItem from "./listItem";
  import { getConvesation } from './service';
  export default {
    name: "talkList",
    components: {
      listItem
    },
    created() {
      var self = this
      getConvesation().then(conversations => {
        self.conversations = conversations
      })
    },
    data() {
      var self = this;
      return {
        conversations: [],
        actions: [
          {
            name: "个人设置",
            method() {
              self.$router.push("/self");
            }
          }
        ],
        sheetVisible: false
      };
    }
  };
</script>
<style lang="less" scoped>
  header {
    padding-left: 15px;
    padding-right: 15px;
    height: 60px;
    display: flex;
    align-items: center;
    border-bottom: 1px solid #eee;
    box-shadow: 1px 1px 1px #eee;

    .searchBar {
      border: none;
      background: #eee;
      border-radius: 50px;
      flex: 1;
      padding-left: 20px;
      margin-left: 15px;
      margin-right: 15px;
    }
  }

  .bottom {
    justify-content: center;
    padding-left: 10px;
    padding-right: 10px;
    display: flex;
    position: fixed;
    bottom: 0;
    width: 100%;
    border-top: 1px solid #eee;
    max-width: 750px;
    height: 60px;
    align-items: center;

    .item {
      &:last-child {
        margin-left: 50px;
      }

      i {
        font-size: 20px;
      }

      display: flex;
      align-items: center;
      flex-direction: column;
      justify-content: center;

      &.active {
        color: green;
      }
    }
  }
</style>